<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8" />
  <title>编辑用户</title>
  <link href="https://cdn.staticfile.org/twitter-bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<div class="container mt-5">
  <h2>编辑用户</h2>
  <form th:action="@{/admin/users/edit}" method="post">
    <input type="hidden" name="id" th:value="${user.id}" />
    <div class="mb-3">
      <label>用户名</label>
      <input type="text" name="username" class="form-control" th:value="${user.username}" required />
    </div>
    <div class="mb-3">
      <label>密码</label>
      <input type="password" name="password" class="form-control" placeholder="留空表示不修改密码" />
    </div>
    <div class="mb-3">
      <label>角色</label>
      <select name="role" class="form-select" th:value="${user.role}">
        <option value="ADMIN" th:selected="${user.role == 'ADMIN'}">管理员</option>
        <option value="USER" th:selected="${user.role == 'USER'}">客户</option>
      </select>
    </div>
    <button type="submit" class="btn btn-primary">保存</button>
    <a href="/admin/users" class="btn btn-secondary">取消</a>
  </form>
</div>
</body>
</html>
